/**
 * Copyright - Accor - All Rights Reserved www.accorhotels.com
 */
package com.my.imq.business.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.genericdao.search.Search;
import com.my.imq.business.BrokerService;
import com.my.imq.dao.BrokerDao;
import com.my.imq.model.Broker;

/**
 * @author <a href="MABDELOUHAB">MABDELOUHAB</a>
 * created 25 janv. 2013
 * @since 
 * @version $Id$
 */
@Transactional
@Service(value="brokerService")
public class BrokerServiceImpl implements BrokerService
{
    @Autowired
    BrokerDao brokerDao;
    
    
    /* (non-Javadoc)
     * @see com.hamada.imq.service.BrokerService#persist(com.hamada.imq.model.Broker)
     */
    public void persist( Broker broker )
    {
        brokerDao.persist( broker );
    }

    /* (non-Javadoc)
     * @see com.hamada.imq.service.BrokerService#findAll()
     */
    public List<Broker> findAll()
    {
        return brokerDao.findAll();
    }

    /* (non-Javadoc)
     * @see com.hamada.imq.service.BrokerService#flush()
     */
    public void flush()
    {
        brokerDao.flush();
    }

    /**
     * @param brokerDao the brokerDao to set
     */
    public void setBrokerDao( BrokerDao brokerDao )
    {
        this.brokerDao = brokerDao;
    }

    /* (non-Javadoc)
     * @see com.my.imq.business.BrokerService#findBetweenDate(java.util.Date, java.util.Date)
     */
    @Override
    public List<Broker> findBetweenDate( Date dateStart, Date dateEnd )
    {
        Search search = new Search(Broker.class);

        search.addFilterLessOrEqual( "time", dateEnd);
        
        search.addFilterGreaterThan( "time", dateStart );
        
        List<Broker> brokers=this.brokerDao.search( search );
        
        return brokers;
    }

}
